<template>
  <div>
    <breadcrumb
      :breadcrumbArr="breadcrumbArr"
      :breadcrumbLastItem="breadcrumbLastItem"
      state="detail"
      @handleBack="handleBack(from)"
    />
    <div class="financeWarehousingDetail">
      <div v-if="state === 'Outbound' || state === 'OutboundDetail'">
        <financialOutbound ref="financialOutbound" />
      </div>
      <div v-else-if="state === 'WriteOff' || state === 'WriteOffDetail'">
        <financialWriteOffDetails ref="financialWriteOffDetails" />
      </div>
    </div>
    <div v-if="state === 'Outbound' || state === 'WriteOff'">
      <approvalOperate />
      <!--      <export-qr ref="exportQr"></export-qr>-->
    </div>

    <div v-else>
      <!--  底部导航栏及签名导出  -->
      <!--      出库-->
      <bottomGuide
        v-if="isTrue"
        :busiType="$route.query.states == 'OutboundDetail' ? '116' : '115'"
        :approvalStatus="
          $route.query.ifApprovingStatus == '5' ? 'approvaled' : ''
        "
        :pageType="
          $route.query.states == 'OutboundDetail'
            ? 'exwarehousewriteoff/detailExport'
            : 'smpexwarehouse/detailExport'
        "
        :curPageId="$route.query.id"
        :businessCode="businessCode"
        @handleBack="handleBack(from)"
      />
    </div>
  </div>
</template>

<script>
import financialOutbound from "../../financialOutbound/views/item_detail";
import financialWriteOffDetails from "../../financialWriteOff/financialWriteOffDetails/views/index";
import approvalOperate from "@/basa/components/public/approval/approval-operate";
import publicComponent from "@/basa/components/public";
// import exportQr from "@/basa/components/public/exportQr";

export default {
  components: {
    bottomGuide: publicComponent.bottomGuide,
    breadcrumb: publicComponent.breadcrumb,
    approvalOperate,
    financialOutbound,
    financialWriteOffDetails
  },
  data() {
    return {
      isTrue: false,
      businessCode: "",
      // 面包屑导航
      breadcrumbArr: [
        {
          path: "/inventoryManagement/storeManagement/storeManagementList",
          text: "库存管理"
        },
        {
          path: "/inventoryManagement/writeOff/ListAll",
          text: "财务出库管理"
        },
        {
          path: "/inventoryManagement/outBoundApprove/approvalPending",
          text: "财务出库审批"
        }
      ]
    };
  },
  computed: {
    breadcrumbLastItem() {
      return this.$route.query.name;
    },
    state() {
      return this.$route.query.states;
    },
    from() {
      return this.$route.query.from;
    }
  },
  activated() {
    if (this.$route.query.states === "OutboundDetail") {
      this.businessCode = this.$refs.financialOutbound.businessCode;
    } else {
      this.businessCode = this.$refs.financialWriteOffDetails.businessCode;
    }
    this.isTrue = true;
  },
  deactivated() {
    this.isTrue = false;
  },
  methods: {
    handleBack(from) {
      let urlList = {
        all: "/inventoryManagement/outBoundApprove/approvalAll",
        pass: "/inventoryManagement/outBoundApprove/approvalPass",
        pending: "/inventoryManagement/outBoundApprove/approvalPending"
      };
      this.$router.push(urlList[from]);
      // if(from === 'all'){
      //   this.$router.push("/financial/outBoundApprove/approvalAll");
      // }else if (from === 'pass'){
      //   this.$router.push("/financial/outBoundApprove/approvalPass");
      // }else {
      //   this.$router.push("/financial/outBoundApprove/approvalPending");
      // }
    }
  }
};
</script>

<style lang="scss">
.financeWarehousingDetail {
  .ccui-navigation {
    display: none;
  }
  .el-bottom-guide {
    display: none;
  }
  .approval-navigation {
    &.ccui-navigation {
      display: block;
    }
  }
}
</style>
